package com.zhangwei.yueshijia.base;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.umeng.analytics.MobclickAgent;
import com.zhangwei.yueshijia.utils.AppManager;

import butterknife.ButterKnife;


public abstract class BaseActivity extends AppCompatActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        AppManager.getAppManager().addActivity(this);
        initBefore(savedInstanceState);
        ButterKnife.bind(this);
        init();
    }

    public void initBefore(Bundle savedInstanceState) {

    }

    @Override
    public void onBackPressed() {
        AppManager.getAppManager().finishActivity();
    }

    protected void init() {
        initView();
        initData();
    }

    protected abstract void initView();

    protected abstract void initData();

    protected abstract int getLayoutId();


    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }
}
